// Created by WXX on 2021/10/22 19:11
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    double myPow(double x, int n) {

        typedef long long LL;

        bool is_minus = n < 0;
        double res = 1;
        for (LL k = abs(LL(n)); k; k >>= 1) {
            if (k & 1) res *= x;
            x *= x;
        }
        if (is_minus) res = 1 / res;
        return res;
    }
};

int main() {

    cout << Solution().myPow(2.0, 10) << endl;
    cout << Solution().myPow(2.0, -2) << endl;

    return 0;
}
